package com.bs.web.rest;

import com.bs.domain.ServiceInfo;
import com.bs.service.SlowSqlBySvcService;
import com.bs.service.SlowSvcService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@Api(value = "logmanager")
@RestController
@RequestMapping("/api/logmanager")
public class SlowSvcResource {

    @Autowired
    private SlowSvcService slowSvcService;
    @Autowired
    private SlowSqlBySvcService slowSqlBySvcService;

    @GetMapping("/slowService")
    public List<Map<String, String>> slowServiceResource(@RequestParam("startTime") String startTime,
                                                         @RequestParam("endTime") String endTime,
                                                         @RequestParam("partition") String partition,
                                                         @RequestParam("time") long time,
                                                         @RequestParam("code") String code

    ) {
        return slowSvcService.slowSvcResource(partition, startTime, endTime, time, code);
    }




    @GetMapping("/findSvc")
    public List findSvcResource(@RequestParam("svc") String svc) {
        return slowSvcService.findSvc(svc);
    }


    @GetMapping("/slowSql")
    public List<ServiceInfo> slowSqlResource(@RequestParam("startTime") String startTime,
                                             @RequestParam("endTime") String endTime,
                                             @RequestParam("partition") String partition,
                                             @RequestParam("svc") String svc,
                                             @RequestParam("code") String code

    ) {
        return slowSqlBySvcService.slowSqlResource( startTime, endTime,partition, svc,code);

    }


}
